package com.mzx.javase.常用类;


import java.util.HashMap;

/**
 * @Description:String类的用法
 * @Date: 2022/3/23 17:09
 * @Author: MarKing
 */
public class StringDemo {
    public static void main(String[] args) {
        //创建字符串几种方式
        //1、构造方法
        String str1 = "abcdefg";
        String str2 = new String("abcdefg");

        //2、字符数组构建字符串
        char[] chars = {'a', 'b', 'c', 'd', 'e'};
        String str3 = new String(chars);
        //3、字节数组构建字符串
        byte[] b = {97, 98, 99, 100};
        String str4 = new String(b);
        System.out.println("str1:" + str1);
        System.out.println("str2:" + str2);
        System.out.println("str3:" + str3);
        System.out.println("str3:" + str4);

        String str5 = new String(b, 1, 3);
        String str6 = new String(chars, 1, 4);
        System.out.println(str5 + "===================="+str6);

        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("aaa", "这是aaa");
        hashMap.put("bbb", "这是bbb");
        HashMap<String, String> copyhashmap = new HashMap<>(hashMap);
        hashMap.put("ccc", "这是ccc");
        hashMap.put("aaa", "这是ccc");
        System.out.println(copyhashmap);
    }

}
